home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / stuffit.arc / GETFLEN.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-11-18  |  1.6 KB  |  82 lines

  1.         
  2. ;GETFLEN.ASM
  3. ;
  4. ;6.12.85
  5.  
  6. comment ~
  7.  
  8.     Get file length
  9.  
  10. On entry:
  11.     DX    address of dpathfilename.ext ASCIIZ string
  12.  
  13. On exit:
  14.     losiz        file size: low word
  15.     hisiz        file size: high word
  16.  
  17. Error returns if CY is set:
  18.     1    invalid function number
  19.     6    invalid handle
  20.  
  21. Uses:
  22.  
  23. Notes:
  24.  
  25. ~
  26.  
  27. ;----------------------------------------------------------
  28. ;        constants and messages
  29.  
  30. gflen_msg    db    cr,lf,'getflen: ',eos
  31.  
  32. ;----------------------------------------------------------
  33. ;        data storage
  34.  
  35. losiz   dw      0                       ;file size: low word
  36. hisiz   dw      0                       ;file size: high word
  37.  
  38. ;----------------------------------------------------------
  39. ;        main code section
  40.  
  41. GETFLEN        proc    near
  42.  
  43. ;open the file:
  44.                     ;DX has offset to ASCIIZ on entry
  45.         mov    ax,3d00h    ;open for read function combo 
  46.         int    21h
  47.         jc    gflen_err
  48.         mov    bx,ax        ;handle to BX
  49.  
  50. get_file_space:
  51.             xor     cx,cx           ;zero offset..
  52.             xor     dx,dx           ;..zero most significant part of offset
  53.             mov     al,2            ;move to end of file plus zero offset
  54.                     ;BX has handle
  55.             mov     ah,42H          ;use lseek to find end of file
  56.             int     21H
  57.         jc    gflen_err
  58.  
  59.  
  60.             mov     hisiz,dx        ;msw in hisiz
  61.             mov     losiz,ax        ;lsw in losiz
  62.  
  63. ;close the file:
  64.                     ;BX has handle
  65.         mov    ah,3eh        ;close file handle function call
  66.         int    21h
  67.         jc    gflen_err
  68.             ret
  69.  
  70. gflen_err:
  71.         push    ax        ;save error code
  72.         mov    dx,offset gflen_msg
  73.         mov    ah,9h        ;print string function call
  74.         int    21h
  75.         pop    ax
  76.         call    errmsg
  77.         stc
  78.         ret
  79.  
  80. getflen        endp
  81.  
  82.